package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *  攻略目录
 */
@Setter
@Getter
@JsonIgnoreProperties({"handler"}) //忽略转换json的属性
public class StrategyCatalog extends BaseDomain{
    //名称
    private String name;
    //所属攻略
    private Strategy strategy;
    //序号
    private Integer sequence;
    //状态
    private Boolean state; //启用/禁用
    //文章集合
    private List<StrategyDetail> details = new ArrayList<>();

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        //将需要的数据添加到map集合中
        map.put("id",id);
        map.put("name",name);
        map.put("sequence",sequence);
        map.put("state",state);
        if(strategy!=null) {
            map.put("strategyId", strategy.getId());
        }
        //将map集合转换成json格式的字符串,再返回
        return JSON.toJSONString(map);
    }
}



